Repository navigation
fix(auth): don't call a login cancelled when it saved before Ctrl-C - #484
Merged
Merged
Conversation
saveLogin() holds the credentials lock while it writes the new login and revokes the previous session. A Ctrl-C in that window waited for the lock, found the pending login already replaced, and still printed "Login cancelled." with telemetry "cancelled", although the login was saved. The handler now checks whether the login saved and says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves:
Description
A Ctrl-C right after approving a login could print "Login cancelled." even though the login had saved. The save keeps the credentials lock while it revokes the previous session. The Ctrl-C handler waited for that lock, found nothing left to cancel, and still reported a cancel, in telemetry too. Now it prints "Logged in to Prismic." and records a success. It still exits 130.
This fixes one of the two Bugbot findings on #469. The other one, "Login wipes session if keychain locked", stays as it is on purpose. Only an explicit
prismic loginreplaces a saved login it can't read, and that's the recovery the keychain error suggests. Keeping the old login until the new one saves would mean not saving the pending login, so an agent's next run couldn't continue it.Proved with a local run of the built CLI that held the previous session's revoke for 2 seconds: the base printed "Login cancelled." and this branch prints "Logged in to Prismic.". The new e2e test does the same.
Checklist
Preview
How to QA 1
The Ctrl-C has to land during the save, which is hard to time by hand. The test "reports a login that saved before Ctrl-C as saved" in
test/login.test.tsreproduces it.Reviewed with sol-loop: 1 round with gpt-6.1-sol on high. Sol verdict: approved
Created with Claude Opus 5.5 in Claude Code.
Note
Low Risk
Narrow change to SIGINT handling and login outcome reporting; core save/revoke logic is unchanged aside from recording save state earlier.
Overview
Fixes a race where Ctrl-C during post-approval cleanup (while credentials are saved and the previous refresh token is revoked under the lock) still printed "Login cancelled." and logged telemetry as cancelled even though the session was already persisted.
The login flow now tracks when credentials are written via
login.saved, and the SIGINT handler uses that to emit "Logged in to Prismic.", recordsuccess(including store metadata), and still exit 130 when interruption happens after a save; otherwise behavior stays cancelled.Tests: fake Auth0 supports
delayMson one-off responses to hold/oauth/revoke, plus an e2e case that approves login, interrupts during revoke, and asserts the saved outcome messaging.Reviewed by Cursor Bugbot for commit af30626. Bugbot is set up for automated code reviews on this repo. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩